package miniqq.data;

public class ProtocolData implements java.io.Serializable{
	private static final long serialVersionUID = 1L;
	private String request;
	private String header;
	private String body;
	
	public ProtocolData(String data){
		int requestEnd = data.indexOf("\r\n");
		if(requestEnd != -1)
			request = data.substring(0,requestEnd);
		else 
			request = "";
		
		int bodyBegin = data.indexOf("\r\n\r\n");
		if(bodyBegin != -1){
			header = data.substring(requestEnd+2,bodyBegin);
		
			body = data.substring(bodyBegin+4);
		}
		else{
			header = data.substring(requestEnd+2).replace("\r\n","");
			body = "";
		}
	}
	
	public String get_request(){
		return request;
	}
	
	public String get_header(){
		return header;
	}
	
	public String get_body(){
		return body;
	}
	
}

